Skip to content

はじめに

aosは、プロセスや契約を構築するための異なるアプローチを提供します。aoコンピュータは、計算がどこでも実行できる分散型コンピュータネットワークであり、aosはユニークなインタラクティブシェルを持っています。あなたは、aosを個人的なオペレーティングシステム、aoプロセスを構築するための開発環境、そしてボットアーミーとして利用できます。

基本的なコマンドをいくつか見ていきましょう。

変数

コンソールを通じて任意の変数の内容を表示したい場合は、単に変数名を入力してください。

lua
Name

インボックス

Inboxは、あなたのプロセスが受信したメッセージのコレクションです。

lua
Inbox[1]

メッセージのカウントを取得したい場合は、#Inboxの前に追加してください。

lua
#Inbox

インボックスに何件のメッセージがあるかを確認するプロセスは非常に一般的なパターンです。これを簡単にするために、インボックス内のメッセージ数を返し、それをプロンプトに表示する関数を作成できます。

.editorまたは.load fileを使用して、この関数をプロセスにロードしてください。

lua
function Prompt()
  return "Inbox: " .. #Inbox .. " > "
end

The Expected Results:

lua
undefined
Inbox: 2 >

あなたのプロンプトは、インボックス内のメッセージ数を含むように変更されました。

グローバル

aosプロセスには、開発を少し直感的にするためのいくつかのグローバル変数があります。

NameDescriptionType
InboxThis is a lua Table that stores all the messages that are received and not handlers by any handlers.Table(Array)
Send(Message)This is a global function that is available in the interactive environment that allows you to send messages to Processesfunction
Spawn(Module, Message)This is a global function that is available in the aos interactive environment that allows you to spawn processes
Namea string that is set on init that describes the name of your processstring
Ownera string that is set on the init of the process that documents the owner of the process, warning if you change this value, it can brick you ability to interact with your processstring
Handlersa lua Table that contains helper functions that allows you to create handlers that execute functionality based on the pattern matching function on inbound messagestable
Dumpa function that takes any lua Table and generates a print friendly output of the datafunction
Utilsa functional utility library with functions like map, reduce, filtermodule
aothis is a core function library for sending messages and spawing processesmodule

モジュール

aosには、すでに利用可能な一般的なLuaモジュールがいくつか組み込まれており、これらのモジュールはrequire関数で参照できます。

NameDescription
jsona json module that allows you to encode and decode json documents
aocontains ao specific functions like send and spawn
.base64a base64 module that allows you to encode and decode base64 text
.prettya pretty print module using the function tprint to output formatted syntax
.utilsan utility function library